﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Register.Model;
using Register.IDAL;
using Register.DBUtility;
using Register.Command;
using System.Data;
namespace Register.DAL
{
    /// <summary> 
    /// FileName: IAppointmentDAL.cs    
    /// CLRVersion: 4.0.30319.269    
    /// Author: DoubleZ    
    /// Corporation:     
    /// Description:     
    /// DateTime: 2012/7/13 17:11:59    
    /// </summary>
   public class AppointmentDAL:IAppointmentDAL
   {
       string tableName = "System_appointment";
       #region 获取预约信息
   public  List<Model.AppointmentInfo> GetPagedAppointmentInfoInfo(int size, int pageIndex, string where) {
       return DataSetToList(DbHelperSQL.getPagedData(" * ", "Appointment_AddTime", where, tableName, OrderBy.DESC, pageIndex, size));
       }
    public   int GetAppointmentInfoInfoCount(string where) {
        int count = 0;
        StringBuilder str = new StringBuilder();
        str.Append(" select count(*) from ");
        str.Append(tableName);
        if (where != null)
        {
            str.Append(" where ");
            str.Append(where);
            count = (int)DbHelperSQL.GetSingle(str.ToString());
        }
        else
        {
            count = (int)DbHelperSQL.GetSingle(str.ToString());
        }
        return count;
     
       }
    private List<Model.AppointmentInfo> DataSetToList(DataSet ds)
    {
        List<Model.AppointmentInfo> list = new List<Model.AppointmentInfo>();
        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            AppointmentInfo app = new AppointmentInfo();
            app.Appointment_ID = (string)dr["Appointment_ID"];
            app.Departments_ID = (string)dr["Departments_ID"];
            app.Doctor_ID = (string)dr["Doctor_ID"];
            app.Appointment_LastNumber = (int)dr["Appointment_LastNumber"];
            app.Appointment_TimeType = (string)dr["Appointment_TimeType"];
            app.Appointment_DayTime = (DateTime)dr["Appointment_DayTime"];
            app.Appointment_OutpatientType = (string)dr["Appointment_OutpatientType"];
            app.Appointment_RegisteredNumber = (int)dr["Appointment_RegisteredNumber"];
            app.Appointment_RegistrationFee = (decimal)dr["Appointment_RegistrationFee"];
            app.Appointment_AlreadyRegisteredNumber = (int)dr["Appointment_AlreadyRegisteredNumber"];
            app.Appointment_Status = (string)dr["Appointment_Status"];
            app.Appointment_AddTime = (DateTime)dr["Appointment_AddTime"];
            app.Appointment_Recoder = (string)dr["Appointment_Recoder"];
            list.Add(app);
        }
        return list;
    }
       #endregion

   }
}
